
Page({
  data: {
    selectIndex: '',
    position: [],
    list: [
      {
        name: '幼儿照护',
        id: 0,
        ch: false
      },
      {
        name: '母婴护理',
        id: 1,
        ch: false
      },
      {
        name: '居家养老',
        id: 2,
        ch: false
      },
      {
        name: '家务料理',
        id: 3,
        ch: false
      },
      {
        name: '家庭保洁',
        id: 4,
        ch: false
      },
      {
        name: '家庭管家',
        id: 5,
        ch: false
      },
      {
        name: '儿童陪伴',
        id: 6,
        ch: false
      },
      {
        name: '临时钟点',
        id: 7,
        ch: false
      },
      {
        name: '其它',
        id: 8,
        ch: false
      },
    ],
    selectIndex2: '',
    workStatus: '',
    list2: [
      {
        name: '待岗中',
        id: 0
      },
      {
        name: '上户中',
        id: 1
      },
    ],
    selectIndex3: '',
    workingYears: '',
    list3: [
      {
        name: '1',
        id: 0
      },
      {
        name: '2',
        id: 1
      },
      {
        name: '3',
        id: 2
      },
      {
        name: '4',
        id: 3
      },
      {
        name: '5',
        id: 4
      },
      {
        name: '6',
        id: 5
      },
      {
        name: '7',
        id: 6
      },
      {
        name: '8',
        id: 7
      },
      {
        name: '9',
        id: 8
      },
      {
        name: '10年以上',
        id: 9
      },
    ]
  },
  clickItem(e) {
    const data = e.currentTarget.dataset;
    let ch = data.item.ch ? false : true;
    let list = this.data.list;
    list.forEach(item => {
      if (item.id == data.item.id) {
        item.ch = ch
      }
    })
    this.setData({
      list: list
    })
  },
  clickItem2(e) {
    console.log(e)
    const data = e.currentTarget.dataset;
    this.setData({
      selectIndex2: data.index,
      workStatus: data.item.name
    })
  },
  clickItem3(e) {
    console.log(e)
    const data = e.currentTarget.dataset;
    this.setData({
      selectIndex3: data.index,
      workingYears: data.item.name
    })
  },
  doNext() {
    let data = this.data, position = [];
    data.list.forEach(item => {
      if (item.ch) {
        position.push(item.name)
      }
    })
    if (position.length == 0) {
      wx.showModal({
        title: '温馨提示',
        content: '求职意向不能为空！',
        confirmColor: '#F08302',
        showCancel: false,
        success(res) {
        }
      })
      return
    }
    if (data.workStatus === '' || data.workStatus == null) {
      wx.showModal({
        title: '温馨提示',
        content: '工作状态不能为空！',
        confirmColor: '#F08302',
        showCancel: false,
        success(res) {
        }
      })
      return
    }
    if (data.workingYears === '' || data.workingYears == null) {
      wx.showModal({
        title: '温馨提示',
        content: '从事的年限不能为空！',
        confirmColor: '#F08302',
        showCancel: false,
        success(res) {
        }
      })
      return
    }
    let storageData = {
      position: position.join(),
      workStatus: data.workStatus,
      workStatusId:data.selectIndex2,
      workingYears: data.workingYears,
      workingYearsId:data.selectIndex3
    }
    wx.setStorageSync('bmhetong', storageData)
    wx.navigateTo({ url: '/page5/bmhetongidcard/index' })
  },


  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  }
  
})